Dominance (C++)

In the C++ programming language, dominance implies a specific behaviour of symbol disambiguation in virtual inheritance. Consider the following example:

class Parent
{
public:
    virtual void function();
};
 
class Child1 : public virtual Parent
{
public:
    void function();
};
 
class Child2 : public virtual Parent
{
};
 
class Grandchild : public Child1, public Child2
{
public:
   Grandchild()
    {
        function();
    }
};

In the Grandchild call to function(), Child1::function is implied, because Child1 is derived from Parent and thus Child1::function "dominates" Parent::function.

See also